# Contributor: rubicon <rubicon@mailo.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=ocaml-charinfo_width
_pkgname=charInfo_width
pkgver=1.1.0
pkgrel=3
pkgdesc="Determine column width for a character in OCaml"
url="https://github.com/kandu/charinfo_width/"
arch="all !riscv64 !loongarch64" # ocaml
license="MIT"
depends_dev="$pkgname=$pkgver-r$pkgrel ocaml-camomile-dev ocaml-result-dev"
makedepends="$depends_dev dune ocaml"
options="!check"  # needs ppx_expect
subpackages="$pkgname-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/kandu/charInfo_width/archive/$pkgver.tar.gz"
builddir="$srcdir/$_pkgname-$pkgver"
_ocamldir=usr/lib/ocaml

# 32-bit archs
case "$CARCH" in
	arm*|x86) options="$options textrels" ;;
esac

build() {
	dune build --release --verbose
}

check() {
	dune runtest --verbose
}

package() {
	dune install \
		--destdir="$pkgdir" \
		--docdir=/.omit
	rm -Rf "$pkgdir"/.omit
}

dev() {
	default_dev

	cd "$pkgdir"

	local path; find $_ocamldir \( \
			-name '*.cmt' -o \
			-name '*.cmti' -o \
			-name '*.ml' -o \
			-name '*.mli' \
		\) | while read -r path
	do
		amove "$path"
	done
}

prepare_py_provides() {
	local datadir="${subpkgdir:-$pkgdir}"
	local pkgbasedir=${pkgbasedir:-"$startdir/pkg"}
	local controldir="$pkgbasedir"/.control.${subpkgname:-$pkgname}

	options_has "!tracedeps" && return 0

	ocaml4-abuild-find provides \
		"$datadir"/usr/lib/ocaml \
		"$controldir" \
		"$pkgver-r$pkgrel"
}

scan_python3_dependency() {
	local controldir="$2" datadir="$3"

	ocaml4-abuild-find requires \
		"$datadir"/usr/lib/ocaml \
		"$controldir"
}

sha512sums="
c8dac9eb6f520213de69b23433e2f0d6a21578c70ae69fb682065e707363968959395a6ddc6c88893e08372a138287318634b52a8b4fb70ac988b4ad4a18b140  ocaml-charinfo_width-1.1.0.tar.gz
"
